<template>
  <view class="goodsfreight" v-if="all_price">
    <view>
      <view v-if="!is_integral">
        {{ $t("submit.price") }}
      </view>
      <view v-else>付款金额</view>
      <view class="add-padding-right">￥{{ all_price.all_goods_price }}</view>
    </view>
    
    <view v-if="all_price.tax_price">
      <view> 发票税额 </view>
      <view class="add-padding-right">+￥{{ all_price.tax_price }}</view>
    </view>

    <template v-if="is_worker">
      <template v-if="mchList[0].payment_type !== 0">
        <view>
          <view>定金费用</view>
          <view class="add-padding-right color26">
            ￥{{ all_price.pre_price || 0 }}
          </view>
        </view>
        <view>
          <view>尾款费用</view>
          <view class="add-padding-right color26">
            ￥{{ all_price.final_price || 0 }}
          </view>
        </view>
      </template>
      <view>
        <view>出行费用</view>
        <view class="add-padding-right color26">
          ￥{{ all_price.travel_price || 0 }}
        </view>
      </view>
    </template>
    <view v-if="is_integral">
      <view>{{ $t("clerk.integral") }}</view>
      <view class="add-padding-right" style="color: #262626">
        {{ all_price.all_integral || 0 }}
      </view>
    </view>

    <view v-if="!is_worker">
      <!-- <view>{{ $t("goods.freight") }}</view> -->
      <view>运费</view>
      <view class="add-padding-right"
        >+ ￥{{ all_price.all_express_price }}</view
      >
    </view>
    <view v-if="!is_worker">
      <!-- <view>{{ $t("mdAdmin.money") }}</view> -->
      <view>配送费</view>
      <view class="add-padding-right"
        >+ ￥{{ all_price.all_delivery_price }}</view
      >
    </view>
    <view v-if="!is_worker && all_price.rand_discount_price > 0">
      <!-- <view>{{ $t("mdAdmin.money") }}</view> -->
      <view>随机立减</view>
      <view class="add-padding-right"
        >- ￥{{ all_price.rand_discount_price }}</view
      >
    </view>
    <view v-if="!is_worker && !is_integral">
      <!-- <view>{{ $t("common.coupon") }}</view> -->
      <view>优惠券</view>
      <view class="add-padding-right"
        >- ￥{{ all_price.all_coupon_price }}</view
      >
    </view>
    <view @click="handleIntegral" v-if="!is_worker && !is_integral">
      <!-- <view>{{ $t("clerk.integral") }}</view> -->
      <view>{{ stores.integral_name }}抵扣</view>
      <view class="flex-box">
        <view>- ￥{{ all_price.all_integral_price }}</view>
        <u-icon size="22" color="#CDCDCD" name="arrow-right"></u-icon>
      </view>
    </view>

    <template v-if="stores.balance">
      <view @click="handleBalance" v-if="!is_worker && !is_integral">
        <view>余额抵扣</view>
        <view class="flex-box">
          <view>- ￥{{ all_price.all_balance }}</view>
          <u-icon size="22" color="#CDCDCD" name="arrow-right"></u-icon>
        </view>
      </view>
    </template>
    <view class="totleIntegral" v-if="is_integral">
      <text>合计：</text>
      <text
        >{{ all_price.all_integral || 0 }}{{ stores.integral_name
        }}{{
          all_price.all_goods_price && all_price.all_goods_price > 0
            ? `+${all_price.all_goods_price}元`
            : ""
        }}</text
      >
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {};
  },
  props: {
    all_price: {
      type: Object,
      default: function () {
        return null;
      }
    },
    is_integral: {
      type: Boolean,
      default: false
    },
    is_worker: {
      default: ""
    },

    mchList: {
      type: Array,
      default() {
        return [];
      }
    }
  },
  methods: {
    handleIntegral() {
      this.$emit("handleIntegral");
    },
    handleBalance() {
      this.$emit("handleBalance");
    }
  }
};
</script>

<style lang="scss" scoped>
view {
  color: #262626;
  font-size: 28rpx;
}
.goodsfreight {
  margin-top: 24rpx;
  padding: 30rpx 24rpx 0;
  background-color: #ffffff;
  > view {
    padding-bottom: 30rpx;
    display: flex;
    align-items: center;
    justify-content: space-between;
    view:last-child {
      color: #f2270c;
      font-weight: bold;
    }
  }
  > view:first-child {
    margin-top: 0rpx;
    view:last-child {
      color: #262626;
      font-weight: bold;
    }
  }
  .flex-box {
    display: flex;
    align-items: center;
    view:first-child {
      color: #f2270c;
      font-weight: bold;
      margin-right: 5rpx;
    }
  }
  .add-padding-right {
    padding-right: 28rpx;
  }
  .totleIntegral {
    display: flex;
    align-items: center;
    padding: 24rpx 0;
    justify-content: flex-end;
    font-size: 26rpx;
    color: #262626;
    border-top: 1px solid #f8f8f8;
    text:nth-child(2) {
      color: #f0250e;
      font-weight: 600;
    }
  }
}

.color26 {
  color: #262626 !important;
}
</style>
